package com.xinwei.leetcode.链表;


// https://leetcode-cn.com/problems/middle-of-the-linked-list/
public class _876_链表的中间节点 {
    public ListNode middleNode(ListNode head) {
        int i = 1;
        ListNode node = head;
        while (node.next != null) {
            i = i + 1;
            node = node.next;
        }
        node = head;
        i = i / 2;
        for (int j = 1; j <= i; j++) {
            node = node.next;
        }
        return node;

    }
}
